from __future__ import annotations

import os
from fastapi import Header, HTTPException, status


def require_token(x_aw_token: str | None = Header(default=None)) -> None:
    expected = os.getenv("AW_API_TOKEN")
    if not expected:
        return
    if x_aw_token != expected:
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token")

